package main

import (
	"net"
	"os"
	"bufio"
	"fmt"
)

func main() {
	conn, _ := net.Dial("tcp", "127.0.0.1:1234")
	defer conn.Close()

	in := bufio.NewReader(os.Stdin)

 	go func() {
		var buf [512]byte
		for {
			n, _ := conn.Read(buf[0:])
			fmt.Println(string(buf[0:n]))
		}
	}()

	for {
		line, _, _ := in.ReadLine()
		fmt.Print("input message",string(line))
		conn.Write(line)
	}

}
